#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
//    ui->setupUi(this);


    reversi_game = new GameEngine();
    bw = new BoardWidget(reversi_game);
    minimax = new Minimax(reversi_game);
    //minimax->start();
    bw->show();
    m_timer.setInterval(1000);
    connect(&m_timer,SIGNAL(timeout()),this,SLOT(cpu_play()));
    m_timer.start();
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::cpu_play(){
    minimax->cpu_play();
    bw->update();
    if(reversi_game->is_finished()){
        m_timer.stop();
    }
}
